# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Sertonix <sertonix@posteo.net>
pkgname=py3-tpm2-pytss
_pkgname=tpm2-pytss
pkgver=2.3.0
pkgrel=1
pkgdesc="Python bindings for TSS"
url="https://github.com/tpm2-software/tpm2-pytss"
arch="all"
license="BSD-2-Clause"
checkdepends="
	py3-pytest-forked
	py3-pytest-xdist
	swtpm
	tpm2-tss-tcti-swtpm
	"
makedepends="
	py3-gpep517
	py3-pkgconfig
	py3-setuptools
	py3-setuptools_scm
	py3-wheel
	python3-dev
	tpm2-tss-dev
	tpm2-tss-rc
	tpm2-tss-fapi
	tpm2-tss-esys
	tpm2-tss-esys
	tpm2-tss-tctildr
	tpm2-tss-policy
	"
depends="
	py3-asn1crypto
	py3-cparser
	py3-cryptography
	py3-yaml
	python3
	"
subpackages="$pkgname-pyc"
source="https://github.com/tpm2-software/tpm2-pytss/archive/$pkgver/$_pkgname-$pkgver.tar.gz
	disable-test.patch
	pycparser.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
4c4d4ba8f31b8e41b8813187931afaca6692570fa081f6a11bb15c76ecd97883efe5f3491e6b38342e8cc3735211c4a17898a11bb3451abbdca60e87acd610b1  tpm2-pytss-2.3.0.tar.gz
e8dd5dee704d82cd3cbc3487a1bfd9f3906639cc6334b32f9ee504cfa701f523ae258a0f5bea5fe663ec2f8e894a6885c76e792c1c62d1ad7b2ac8616e8c9d82  disable-test.patch
6c57ba67b9bf177eeefec020aa46df8f12cd934fb8e598a4231d2c4ab0b03feb3f7144c40dc185e0251eb800ee071254e79f784d0480ab9967c79422475f24bd  pycparser.patch
"
